<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 14-6-23
 * Time: 下午5:47
 */
require 'Common.php';

$data = $_POST['data'];
$akey = $_POST['akey'];
$skey = $_POST['skey'];
$sig = $_POST['sig'];

if(empty($data) || empty($akey) || empty($skey) || empty($sig))
{
    throw new Exception("invalid_request",0);
}

$config_key = C('UPLOAD.REMOTE_KEY');
if($akey!=$config_key){
    throw new Exception("invalid_request_key",0);
}

$key = params_deal(SITE_URL);
$secret = get_secret($akey,$skey);
$new_sig = get_signature($key,$secret);
if($sig!=$new_sig){
    throw new Exception("invalid_request",0);
}

//更新配置文件
$data = json_decode($data,true);
cache('attach',$data);

json_exit(array('error'=>0));